import os


def ln(from_path, to, filter_fu):
    for root, dirs, files in os.walk(from_path):
        for file in files:
            if not filter_fu(file):
                continue
            os.system(f"ln -sf {from_path}/{file} {to}")


if __name__ == '__main__':
    ln("/kaggle/input/pig-line-text-cover/train/images", "dataset/train", lambda x: x.find("gray") > 0)
    ln("/kaggle/input/pig-line-text-cover/train/labels", "dataset/train", lambda x: x.find("gray") > 0)
    ln("/kaggle/input/pig-line-text-cover/val/images", "dataset/val", lambda x: x.find("gray") > 0)
    ln("/kaggle/input/pig-line-text-cover/val/labels", "dataset/val", lambda x: x.find("gray") > 0)
